package org.neframework.webtest.action.version;

import java.util.List;
import java.util.Map;

import org.neframework.webtest.model.t_fk_version;
import org.neframework.webtest.service.VersionService;

import org.neframework.webtest.base.BaseController;
import com.tmsps.neframework.mvc.annotation.Controller;
import com.tmsps.neframework.mvc.annotation.RequestMapping;
import com.tmsps.neframework.mvc.annotation.ResponseBody;
import com.tmsps.neframework.mvc.plugin.Tip;

@Controller
@RequestMapping("/cp/version")
public class VersionController extends BaseController {

	private static final VersionService vService = new VersionService();
	
	@RequestMapping("/list")
	public String list() {
		return "/jsp/version/list.jsp";
	}
	
	@RequestMapping("/list_data")
	@ResponseBody
	public void list_data() {

		List<Map<String, Object>> list = vService.selectVersionList();

		result.put("list", list);
	}
	
	@RequestMapping("/edit")
	@ResponseBody
	public void save(String val,String msg,String kid) {
		
		t_fk_version vn = (t_fk_version) oc.findObjById(kid, t_fk_version.class);
		if("version".equals(msg)){
			vn.setVersion(val);
		}else{
			vn.setNote(val);
		}
		oc.updateObj(vn);

		this.setTipMsg(true, "保存成功!", Tip.Type.success);		
	}
}
